package com.ruoyi.web.controller.video;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.video.domain.VideoCompany;
import com.ruoyi.video.service.IVideoCompanyService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公司Controller
 * 
 * @author ruoyi
 * @date 2025-06-07
 */
@Controller
@RequestMapping("/video/company")
@Api("公司接口")
public class VideoCompanyController extends BaseController
{
    private String prefix = "video/company";

    @Autowired
    private IVideoCompanyService videoCompanyService;

    @RequiresPermissions("video:company:view")
    @GetMapping()
    public String company()
    {
        return prefix + "/company";
    }

    /**
     * 查询公司列表
     */
    @RequiresPermissions("video:company:list")
    @PostMapping("/list")
    @ResponseBody
    @ApiOperation("公司列表分页查询")
    public TableDataInfo list(VideoCompany videoCompany)
    {
        startPage();
        List<VideoCompany> list = videoCompanyService.selectVideoCompanyList(videoCompany);
        return getDataTable(list);
    }

    /**
     * 导出公司列表
     */
    @RequiresPermissions("video:company:export")
    @Log(title = "公司", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(VideoCompany videoCompany)
    {
        List<VideoCompany> list = videoCompanyService.selectVideoCompanyList(videoCompany);
        ExcelUtil<VideoCompany> util = new ExcelUtil<VideoCompany>(VideoCompany.class);
        return util.exportExcel(list, "公司数据");
    }

    /**
     * 新增公司
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存公司
     */
    @RequiresPermissions("video:company:add")
    @Log(title = "公司", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    @ApiOperation("新增公司")
    public AjaxResult addSave(VideoCompany videoCompany)
    {
        return toAjax(videoCompanyService.insertVideoCompany(videoCompany));
    }

    /**
     * 修改公司
     */
    @RequiresPermissions("video:company:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap)
    {
        VideoCompany videoCompany = videoCompanyService.selectVideoCompanyById(id);
        mmap.put("videoCompany", videoCompany);
        return prefix + "/edit";
    }

    /**
     * 修改保存公司
     */
    @RequiresPermissions("video:company:edit")
    @Log(title = "公司", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    @ApiOperation("修改公司")
    public AjaxResult editSave(VideoCompany videoCompany)
    {
        return toAjax(videoCompanyService.updateVideoCompany(videoCompany));
    }

    /**
     * 删除公司
     */
    @RequiresPermissions("video:company:remove")
    @Log(title = "公司", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    @ApiOperation("删除公司")
    public AjaxResult remove(String ids)
    {
        return toAjax(videoCompanyService.deleteVideoCompanyByIds(ids));
    }
}
